/*
 * Jp_PlanningTechnicien.java
 *
 * Created on 4 mai 2008, 12:42
 */

package gui;

import IBO.IClientParticulier;
import IBO.IClientSociete;
import IBO.IIntervention;
import IBO.ITechnicien;
import boerrors.AdresseInexistantException;
import boerrors.ClientInexistantException;
import boerrors.CodePostalMinimumMultiplicityException;
import boerrors.ZoneMinimumMultiplicityException;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

/**
 *
 * @author  olivierm
 */
public class Jp_PlanningTechnicien extends javax.swing.JPanel {
    
    DefaultComboBoxModel _modeleLstTechniciens = new DefaultComboBoxModel();
    DefaultListModel _modeleInterventions = new DefaultListModel();
    private Frm_Application _parent = null;
    private IIntervention _intervention = null;
    private ITechnicien _technicien = null;
    private Vector<ITechnicien> _listeTechnicien = null;
    private Vector<IIntervention> _listeInterventions = null;
    
    public void initComponents2(Frm_Application parent){
        this._parent = parent;
        jXDatePicker1.setDate(new java.util.Date());
    }

    private void resetFields(){
            jtxt_Id.setText("");
            jtxt_Priorite.setText("");
            jtxt_Zone.setText("");
            jtxt_Rue.setText("");
            jtxt_Numero.setText("");
            jtxt_Comune.setText("");
            jtxt_Cp.setText("");
            jtxt_Commentaire.setText("");
            jtxt_Commentaire.setText("");
            jtxt_DateCreation.setText("");
            jtxt_DateIntervention.setText("");
            jtxt_Priorite.setText("");
            jtxt_InterventionPriorite.setText("");
            jtxt_Statut.setText("");
    }
    
    private void fillFields(){
        try {
            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
            jtxt_Id.setText(String.valueOf(this._intervention.getIdIntervention()));
            jtxt_Priorite.setText(this._intervention.getPrioriteDemande());
            jtxt_Zone.setText(String.valueOf(this._intervention.getIAdresse().getICodePostal().getZone().getIdZone()) + " - " + this._intervention.getIAdresse().getICodePostal().getZone().getLibelleZone());
            jtxt_Rue.setText(this._intervention.getIAdresse().getRue());
            jtxt_Numero.setText(this._intervention.getIAdresse().getNumero());
            jtxt_Comune.setText(this._intervention.getIAdresse().getICodePostal().getVille());
            jtxt_Cp.setText(this._intervention.getIAdresse().getICodePostal().getCodePostal());
            jtxt_Commentaire.setText(this._intervention.getDescriptionDemande());
            jtxt_Commentaire.setText(this._intervention.getDescriptionDemande());
            Date dateDate = this._intervention.getDateDemande().getTime();
            String dateFormatee = dateFormat.format(dateDate);            
            jtxt_DateCreation.setText(dateFormatee);
            jtxt_Statut.setText(this._intervention.getIStatut());
            if(this._intervention.getDateIntervention() != null){
                Date dateDate2 = this._intervention.getDateIntervention().getTime();
                String dateFormatee2 = dateFormat.format(dateDate2);
                jtxt_DateIntervention.setText(dateFormatee2);}
            if(this._intervention.getPrioriteIntervention() != null)
                jtxt_InterventionPriorite.setText(this._intervention.getPrioriteIntervention());           

        } catch (RemoteException ex) {
            Logger.getLogger(Jp_InterventionDetails.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ZoneMinimumMultiplicityException ex) {
            Logger.getLogger(Jp_AssigneeIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CodePostalMinimumMultiplicityException ex) {
            Logger.getLogger(Jp_AssigneeIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (AdresseInexistantException ex) {
            Logger.getLogger(Jp_AssigneeIntervention.class.getName()).log(Level.SEVERE, null, ex);
        }
    }    
    
    public void setLstTechnicien(){
        try {
            this._listeTechnicien = this._parent.getFactoryRmi().getGestionEmployes().listerTechniciens();
            for (int i = 0; i < this._listeTechnicien.size(); i++) {
                this._modeleLstTechniciens.addElement(this._listeTechnicien.get(i).getMatricule() + " - " + this._listeTechnicien.get(i).getNom() + " " + this._listeTechnicien.get(i).getPrenom());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void setInterventions(){
        for (int i = 0; i < this._listeInterventions.size(); i++){
            try {
                this._modeleInterventions.addElement(this._listeInterventions.get(i).getIdIntervention() + " - " + this._listeInterventions.get(i).getPrioriteIntervention());
            } catch (RemoteException ex) {
                Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    /** Creates new form Jp_PlanningTechnicien */
    public Jp_PlanningTechnicien() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel7 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jXTitledPanel1 = new org.jdesktop.swingx.JXTitledPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jxlist_Interventions = new org.jdesktop.swingx.JXList();
        jPanel5 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jbtn_ClientInfo = new javax.swing.JButton();
        jtxt_Statut = new javax.swing.JTextField();
        jtxt_HeureFin = new javax.swing.JTextField();
        jtxt_HeureDebut = new javax.swing.JTextField();
        jtxt_DateIntervention = new javax.swing.JTextField();
        jtxt_InterventionPriorite = new javax.swing.JTextField();
        jtxt_Zone = new javax.swing.JTextField();
        jtxt_Priorite = new javax.swing.JTextField();
        jtxt_DateCreation = new javax.swing.JTextField();
        jtxt_Id = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtxt_Intervention = new javax.swing.JTextArea();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtxt_Commentaire = new javax.swing.JTextArea();
        jtxt_Comune = new javax.swing.JTextField();
        jtxt_Rue = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jtxt_Numero = new javax.swing.JTextField();
        jtxt_Cp = new javax.swing.JTextField();
        jXTaskPane1 = new org.jdesktop.swingx.JXTaskPane();
        jPanel3 = new javax.swing.JPanel();
        jbtn_Rechercher = new javax.swing.JButton();
        jXDatePicker1 = new org.jdesktop.swingx.JXDatePicker();
        jccb_listeTechniciens = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jbtn_Fermer = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        jPanel7.setBackground(new java.awt.Color(0, 102, 153));
        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setFont(new java.awt.Font("Tahoma", 3, 14));
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Planning des techniciens");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addContainerGap(654, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addContainerGap())
        );

        add(jPanel7, java.awt.BorderLayout.NORTH);

        jPanel1.setLayout(new java.awt.BorderLayout());

        jXTitledPanel1.setTitle(" Planning");

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Liste des interventions"));

        jxlist_Interventions.setModel(_modeleInterventions);
        jxlist_Interventions.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jxlist_InterventionsMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jxlist_Interventions);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Détails"));

        jLabel3.setText("Numéro d'intervention:");

        jLabel4.setText("Date de création:");

        jLabel5.setText("Piorité initiale:");

        jLabel6.setText("Zone de l'intervention:");

        jLabel24.setText("Priorité de l'intervention:");

        jLabel23.setText("Date de l'intervention:");

        jLabel26.setText("Heure de début:");

        jLabel27.setText("Heure de fin:");

        jLabel28.setText("Statut:");

        jbtn_ClientInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/help.png"))); // NOI18N
        jbtn_ClientInfo.setText("Information du client");
        jbtn_ClientInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_ClientInfoActionPerformed(evt);
            }
        });

        jtxt_Statut.setEditable(false);

        jtxt_HeureFin.setEditable(false);

        jtxt_HeureDebut.setEditable(false);

        jtxt_DateIntervention.setEditable(false);

        jtxt_InterventionPriorite.setEditable(false);

        jtxt_Zone.setEditable(false);

        jtxt_Priorite.setEditable(false);

        jtxt_DateCreation.setEditable(false);

        jtxt_Id.setEditable(false);

        jLabel7.setText("Rue:");

        jLabel9.setText("Commune:");

        jLabel8.setText("Demande:");

        jLabel25.setText("Intervention:");

        jtxt_Intervention.setColumns(20);
        jtxt_Intervention.setEditable(false);
        jtxt_Intervention.setRows(5);
        jScrollPane2.setViewportView(jtxt_Intervention);

        jtxt_Commentaire.setColumns(20);
        jtxt_Commentaire.setEditable(false);
        jtxt_Commentaire.setRows(5);
        jScrollPane3.setViewportView(jtxt_Commentaire);

        jtxt_Comune.setEditable(false);

        jtxt_Rue.setEditable(false);

        jLabel10.setText("Numero:");

        jLabel12.setText("Code postal:");

        jtxt_Numero.setEditable(false);

        jtxt_Cp.setEditable(false);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel24)
                            .addComponent(jLabel23)
                            .addComponent(jLabel26)
                            .addComponent(jLabel27)
                            .addComponent(jLabel28))
                        .addGap(13, 13, 13)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jtxt_Statut, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_Id, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_DateCreation, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_Priorite, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_HeureDebut, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_HeureFin, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                .addComponent(jtxt_DateIntervention, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jtxt_Zone, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jtxt_InterventionPriorite, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel9))
                                .addGap(17, 17, 17))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel25)
                                .addGap(18, 18, 18))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addGap(18, 18, 18)))
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtxt_Rue, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE)
                                    .addComponent(jtxt_Comune, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel12))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jtxt_Cp)
                                    .addComponent(jtxt_Numero, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE))))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jbtn_ClientInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 352, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel7)
                    .addComponent(jtxt_Id, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtxt_Numero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jtxt_Rue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel9)
                            .addComponent(jtxt_DateCreation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jtxt_Priorite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtxt_Cp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12)
                            .addComponent(jtxt_Comune, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(jtxt_Zone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel24)
                                    .addComponent(jtxt_InterventionPriorite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel23)
                                    .addComponent(jtxt_DateIntervention, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jtxt_HeureDebut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel26))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jtxt_HeureFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel27))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jtxt_Statut, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel28)))
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel25))))))
                .addGap(3, 3, 3)
                .addComponent(jbtn_ClientInfo)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jXTitledPanel1Layout = new javax.swing.GroupLayout(jXTitledPanel1.getContentContainer());
        jXTitledPanel1.getContentContainer().setLayout(jXTitledPanel1Layout);
        jXTitledPanel1Layout.setHorizontalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXTitledPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jXTitledPanel1Layout.setVerticalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXTitledPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jPanel1.add(jXTitledPanel1, java.awt.BorderLayout.CENTER);

        jXTaskPane1.setTitle("Critères de recherche");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jbtn_Rechercher.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/eye.png"))); // NOI18N
        jbtn_Rechercher.setText("Rechercher");
        jbtn_Rechercher.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_RechercherActionPerformed(evt);
            }
        });

        jccb_listeTechniciens.setModel(_modeleLstTechniciens);

        jLabel1.setText("Sélection du technicien:");

        jLabel2.setText("Sélection de la date:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbtn_Rechercher)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jccb_listeTechniciens, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addGap(18, 18, 18)
                            .addComponent(jXDatePicker1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(499, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jccb_listeTechniciens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jXDatePicker1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtn_Rechercher)
                .addContainerGap())
        );

        jXTaskPane1.getContentPane().add(jPanel3);

        jPanel1.add(jXTaskPane1, java.awt.BorderLayout.PAGE_START);

        add(jPanel1, java.awt.BorderLayout.CENTER);

        jbtn_Fermer.setText("Fermer");
        jbtn_Fermer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_FermerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(758, Short.MAX_VALUE)
                .addComponent(jbtn_Fermer)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jbtn_Fermer)
                .addContainerGap())
        );

        add(jPanel2, java.awt.BorderLayout.SOUTH);
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_ClientInfoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_ClientInfoActionPerformed
        try {
            
            Vector<IClientParticulier> listeCltP = this._parent.getFactoryRmi().getGestionClients().rechercherClientParticulier_NumClient(this._intervention.getIClient().getIdClient());
            if (listeCltP.size() > 0){
                Jd_DetailsClientP jd_Tmp = new Jd_DetailsClientP(this._parent, true);
                jd_Tmp.initComponents2(this._parent, (IClientParticulier)listeCltP.get(0));
                jd_Tmp.setVisible(true);
            }else{
                Vector<IClientSociete> listeCltS = this._parent.getFactoryRmi().getGestionClients().rechercherClientSociete_NumClient(this._intervention.getIClient().getIdClient());
                Jd_DetailsClientS jd_Tmp = new Jd_DetailsClientS(this._parent, true);
                jd_Tmp.initComponents2(this._parent, (IClientSociete)listeCltS.get(0));
                jd_Tmp.setVisible(true);
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClientInexistantException ex) {
            Logger.getLogger(Jp_PlannifierIntervention.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NullPointerException ex){
            JOptionPane.showMessageDialog(this,"Vous ne pouvez voir afficher les informations d'un client que pour une intervention sélectionnée.","Information",JOptionPane.INFORMATION_MESSAGE);
        } catch (ArrayIndexOutOfBoundsException ex){
            JOptionPane.showMessageDialog(this,"Vous ne pouvez voir afficher les informations d'un client que pour une intervention sélectionnée.","Information",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jbtn_ClientInfoActionPerformed

    private void jbtn_RechercherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_RechercherActionPerformed
        try {
            this.resetFields();
            this._modeleInterventions.removeAllElements();
            this._listeInterventions = this._parent.getFactoryRmi().getGestionTechniciens().retrieveInterventions(this._listeTechnicien.get(jccb_listeTechniciens.getSelectedIndex()), jXDatePicker1.getDate());
            for (int i = 0; i < this._listeInterventions.size(); i++){
                this._modeleInterventions.addElement(this._listeInterventions.get(i).getIdIntervention());
            }
        } catch (RemoteException ex) {
            Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
        } catch (AdresseInexistantException ex) {
            Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CodePostalMinimumMultiplicityException ex) {
            Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ZoneMinimumMultiplicityException ex) {
            Logger.getLogger(Jp_PlanningTechnicien.class.getName()).log(Level.SEVERE, null, ex);
        }
    
        
}//GEN-LAST:event_jbtn_RechercherActionPerformed

    private void jxlist_InterventionsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jxlist_InterventionsMouseClicked

        int index = jxlist_Interventions.locationToIndex(evt.getPoint());
        this._intervention = this._listeInterventions.get(index);
        fillFields();
        
}//GEN-LAST:event_jxlist_InterventionsMouseClicked

    private void jbtn_FermerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_FermerActionPerformed
        this.resetFields();
        this.setVisible(false);
        
    }//GEN-LAST:event_jbtn_FermerActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker1;
    private org.jdesktop.swingx.JXTaskPane jXTaskPane1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel1;
    private javax.swing.JButton jbtn_ClientInfo;
    private javax.swing.JButton jbtn_Fermer;
    private javax.swing.JButton jbtn_Rechercher;
    private javax.swing.JComboBox jccb_listeTechniciens;
    private javax.swing.JTextArea jtxt_Commentaire;
    private javax.swing.JTextField jtxt_Comune;
    private javax.swing.JTextField jtxt_Cp;
    private javax.swing.JTextField jtxt_DateCreation;
    private javax.swing.JTextField jtxt_DateIntervention;
    private javax.swing.JTextField jtxt_HeureDebut;
    private javax.swing.JTextField jtxt_HeureFin;
    private javax.swing.JTextField jtxt_Id;
    private javax.swing.JTextArea jtxt_Intervention;
    private javax.swing.JTextField jtxt_InterventionPriorite;
    private javax.swing.JTextField jtxt_Numero;
    private javax.swing.JTextField jtxt_Priorite;
    private javax.swing.JTextField jtxt_Rue;
    private javax.swing.JTextField jtxt_Statut;
    private javax.swing.JTextField jtxt_Zone;
    private org.jdesktop.swingx.JXList jxlist_Interventions;
    // End of variables declaration//GEN-END:variables
    
}
